<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script>
 <link type="text/css" rel="stylesheet" href="${initParam.root }jquery.ratings.css" />
 <script src="${initParam.root }jquery-1.3.2.min.js"></script>
 <script src="${initParam.root }jquery.ratings.js"></script>
<script type="text/javascript">
var itemPrice;
var totalPrice = 0;
$(document).ready(function(){
   $(":input[name=buyItem]").click(function(){
      if(confirm("구매하시겠습니까?")){
         location.href="${initParam.root}item/insertPurchasedItemList.moja?itemNo="+itemNo;
      }else{
         return false;
      }
});
   
   $(":input[name=cartCheck]").change(function(){
      var itemPrice = 0;
      $.ajax({
			type:"post",
			url:"${initParam.root}item/cartCheck.moja",
			data:"price="+$(this).val()+"&totalPrice="+totalPrice,
			dataType:"json",
			success:function(data){
				alert(data);
				totalPrice = data;
      		$("#checkPayView").html(data);
			}
		});//ajax

   });
   
   
   $("#checkAll").click(function() {
	   //alert("상품전체선택 선택");
		$(":input[name=cartCheck]:checkbox").each(function() {
			$(this).attr("checked", true);
			  
		});
	});
   
   $("#uncheckAll").click(function() {
	   //alert("상품전체선택취소 ");
		$("input[name=cartCheck]:checkbox").each(function() {
			$(this).attr("checked", false);
			$("#checkPayView").html("0");
		});
	});
   
    $("#deletecheck").click(function(){
    	alert("삭제버튼 클릭크릭클릭~~~~");
    	//////////////// no를 넘겨야하는데...........ㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠㅠ 저 val는 price인데...ㅠㅠㅠㅠ
    	location.href="${initParam.root}item/cartDelete.moja?itemNo="+$(":input[name=cartCheck]:checked").val();
   }); 
   
   
});

</script>
</head>
<body>
<%-- <div id="mainCss" align="center">
${requestScope.cvo}카트이동
</div> --%>
<div id="mainCss">
<img src="${initParam.root }img/cartTab.jpg" >
<br><br>
<table id="itemTbl" cellpadding="0" cellspacing="0" align="center" border="1">
<thead>
   <th>선택</th><th>상품번호</th><th>상품명</th><th>상세정보</th><th>작성자</th><th>가격</th>
</thead>
<tbody>

<c:forEach items="${requestScope.cvo }" var="cvo">
<tr>
   <td width="30px" align="center">
   <input type="checkbox" name="cartCheck" value="${cvo.itemPrice}"></td>
   <td>${cvo.itemNo}</td>
   <td>${cvo.itemName}</td>
   <td>${cvo.itemInfo}</td>
   <td>${cvo.memberId}</td>
   <td align="right">${cvo.itemPrice}원</td>
</tr>
</c:forEach>

<tr>
<td colspan="6">
<input type="button" id = "checkAll" value="전체선택">
<input type="button" id = "uncheckAll" value="전체취소">
<input type="button" id = "deletecheck" value="삭제">
</td>
</tr>
<tr>
<td colspan="3" rowspan="3">
</td>
<td align="left" bgcolor="#D2D2D2"><font color="#000000">상품 금액 :</font></td>
<td colspan="2"  align="right"><div id="checkPayView" align="right" ></div>원</td>
</tr>
<tr>
<td align="left" bgcolor="#D2D2D2"><font color="#000000">보유 포인트 : </font></td>
<td colspan="2"  align="right">${sessionScope.memberPoint } 쫌</td>
</tr>
<tr>
<td align="left" bgcolor="#D2D2D2"><font color="#000000">결제예정금액 : </font></td>
<td colspan="2" align="right">합계금액!~~~</td>
</tr>
</tbody>
</table>
<br>

<div align="center">
<input type="button" name = "buyItem" value="결제">
</div>
</div>
</body>
</html>